<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*" errorPage="/error.jsp" %>
<%
       response.setHeader("Pragma","No-cache");
       response.setHeader("Cache-Control","no-cache");
       response.setDateHeader("Expires",0);
	   String username;
	   if(session.getAttribute("login_user")!=null)
		{	
			username=(String)session.getAttribute("login_user");
				response.sendRedirect(request.getContextPath()+"/blog/"+username);
		}else{	   
	   String title="登录";
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD><TITLE>博客登录</TITLE>
  <base href="<%=basePath%>">
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="css/login.css" type=text/css rel=stylesheet>
<SCRIPT language=javascript>
	function setfocus()
	{
		if(document.forms[0]['username'].value!='')
		{
			document.forms[0]['password'].focus()
		}
		else
		{
			document.forms[0]['username'].focus()
		}
	}
    </SCRIPT>

<META content="MSHTML 6.00.3790.0" name=GENERATOR></HEAD>
<BODY onload=setfocus()>
<FORM id=frmLogin name=frmLogin onSubmit="javascript:return WebForm_OnSubmit();" 
action=login
method=post>
<DIV><INPUT id=__EVENTTARGET type=hidden name=__EVENTTARGET> <INPUT 
id=__EVENTARGUMENT type=hidden name=__EVENTARGUMENT> <INPUT id=__VIEWSTATE 
type=hidden 
value=/wEPDwUJLTQ4MjY2NzAyZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQULY2hrUmVtZW1iZXKN77H0bJppUD4atWFTG9NqZOflkw== 
name=__VIEWSTATE> </DIV>
<SCRIPT type=text/javascript>
<!--
var theForm = document.forms['frmLogin'];
if (!theForm) {
    theForm = document.frmLogin;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</SCRIPT>

<SCRIPT src="js/WebResource.js" type=text/javascript></SCRIPT>

<SCRIPT language=JavaScript>
NS4 = (document.layers) ? true : false;
function checkEnter(event,element)
{     
    var code = 0;
    if (NS4)
        code = event.which;
    else
        code = event.keyCode;
    if (code==13)
	{
       	if(element.name=='username')
		{
			document.frmLogin.password.focus();
		}
		else if(element.name=='password')
		{
			document.frmLogin.authencode.focus();
		}
		else if(element.name=='authencode')
		{
						if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate()) __doPostBack('lblLogin','');
		}
	}
}

</SCRIPT>

<SCRIPT 
src="js/WebResource2.js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</SCRIPT>

<TABLE id=tbLogin align=center>
  <TBODY>
  <TR>
    <TD>
      <DIV id=Main>
      <DIV id=Heading>请登录</DIV><LABEL class=MyLabel>用户名</LABEL> <INPUT 
      class=Textbox onkeypress=checkEnter(event,this) id=username 
      name=username><BR><SPAN id=Required_UserName 
      style="VISIBILITY: hidden; COLOR: red">用户名不能为空</SPAN> <LABEL 
      class=MyLabel>密码</LABEL> <INPUT class=Textbox 
      onkeypress=checkEnter(event,this) id=password type=password 
      name=password><BR><SPAN id=Required＿Password 
      style="VISIBILITY: hidden; COLOR: red">密码不能为空</SPAN> <SPAN 
      id=Requiredfieldvalidator4 
      style="DISPLAY: none; COLOR: red">请输入验证码</SPAN><BR><SPAN id=lblImage 
      style="FONT-WEIGHT: bold; COLOR: red"></SPAN><IMG src="<%=path %>/AuthenCode?authenName=AuthenCode&heigth=20" alt="" align="absbottom"> <LABEL class=MyLabel>请输入验证码:</LABEL> 
      <INPUT onkeypress=checkEnter(event,this) id=authencode 
      name=authencode> <A class=Button id=lblLogin 
      style="MARGIN-TOP: 8px" 
      href='javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions("lblLogin",%20"",%20true,%20"",%20"",%20false,%20true))'>登录</A> 

      <P style="MARGIN: 4px 0px 0px 20px"><SPAN class=chk><INPUT name=isCookie 
      type=checkbox id=isCookie value="1" checked><LABEL for=isCookie>两周内记住我的登录信息?</LABEL></SPAN></P>
      <P class=Small>&nbsp;&nbsp; <A id=lbSendPassword 
      href="http://www.cnblogs.com/GetMyPassword.aspx"></A>&nbsp;&nbsp; &nbsp;&nbsp;<A 
      href="user/register.jsp">未注册,我要注册</A>     </P>
      <BR 
      style="CLEAR: both"><SPAN class=ErrorMessage id=Message style="COLOR: red" 
      FontBold="true"></SPAN></DIV></TD></TR></TBODY></TABLE>
<SCRIPT type=text/javascript>
<!--
var Page_Validators =  new Array(document.getElementById("Required_UserName"), document.getElementById("Required＿Password"), document.getElementById("Requiredfieldvalidator4"));
// -->
</SCRIPT>

<SCRIPT type=text/javascript>
<!--
var Required_UserName = document.all ? document.all["Required_UserName"] : document.getElementById("Required_UserName");
Required_UserName.controltovalidate = "username";
Required_UserName.errormessage = "用户名不能为空";
Required_UserName.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
Required_UserName.initialvalue = "";
var Required＿Password = document.all ? document.all["Required＿Password"] : document.getElementById("Required＿Password");
Required＿Password.controltovalidate = "password";
Required＿Password.errormessage = "密码不能为空";
Required＿Password.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
Required＿Password.initialvalue = "";
var Requiredfieldvalidator4 = document.all ? document.all["Requiredfieldvalidator4"] : document.getElementById("Requiredfieldvalidator4");
Requiredfieldvalidator4.controltovalidate = "authencode";
Requiredfieldvalidator4.errormessage = "请输入验证码";
Requiredfieldvalidator4.display = "Dynamic";
Requiredfieldvalidator4.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
Requiredfieldvalidator4.initialvalue = "";
// -->
</SCRIPT>

<SCRIPT type=text/javascript>
<!--
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
// -->
</SCRIPT>
</FORM></BODY></HTML>
<%	
  }
%>